package com.nhim.cms.admin.client.customwidget.ui;

import java.util.ArrayList;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.nhim.cms.admin.shared.CustomWidgetPropertyProxy;

public class CustomWidgetPropertyPanel extends VerticalPanel {
	
	private final CustomWidgetPropertyProxy cwProxy;
	ArrayList<String> disPlayValue;
	TextBox textBoxControl;
	TextArea textAreaControl;
	public CustomWidgetPropertyPanel(CustomWidgetPropertyProxy cwProxy,String savedValue)
	{
		super();
		this.cwProxy = cwProxy;
		add(new Label(cwProxy.getDescription()));
		switch(CustomWidgetPropertyProxy.EDisplayType.valueOf(cwProxy.getDisplayType()))
		{
			case Textbox:
				textBoxControl = new TextBox();
				textBoxControl.setText(savedValue);
				add(textBoxControl);
			break;
			case Textarea:
				textAreaControl = new TextArea();
				textAreaControl.setText(savedValue);
				add(textAreaControl);
				break;
		}
		
	}

	public String getDataType()
	{
		return cwProxy.getDataType();
	}
	public String getValue()
	{
		switch(CustomWidgetPropertyProxy.EDisplayType.valueOf(cwProxy.getDisplayType()))
		{
		case Textbox:
			return textBoxControl.getText();

		case Textarea:
			return textAreaControl.getText();
	}
	return "";
		
	}
	public String getName()
	{
		return cwProxy.getName();
	}

	

}
